Imports System.IO

Public Class VerificationForm

    Private Data As List(Of Biometrics)

    Sub New(ByVal data As List(Of Biometrics))
        InitializeComponent()
        Me.Data = data
    End Sub

    Sub OnComplete(ByVal Control As Object, ByVal FeatureSet As DPFP.FeatureSet, ByRef EventHandlerStatus As DPFP.Gui.EventHandlerStatus) Handles VerificationControl.OnComplete
       

        Dim Verificator As New DPFP.Verification.Verification

        ' Check quality of the sample and start verification if it's good
        If Not FeatureSet Is Nothing Then

            Dim template As New DPFP.Template


            For Each bioObject As Biometrics In Data

                Dim b As Byte() = Convert.FromBase64String(bioObject.template_string.Replace("~", "+"))
                Dim ms As MemoryStream = New MemoryStream(b)
                template.DeSerialize(ms)

                Dim result As DPFP.Verification.Verification.Result = New DPFP.Verification.Verification.Result()
                Verificator.Verify(FeatureSet, template, result)

                If result.Verified Then

                    Dim empMgr As New EmployeeManager
                    Dim emp As Employee
                    emp = empMgr.retrieveEmployeeById(bioObject.employee_id)

                    If Not emp Is Nothing Then
                        If emp.role = 1 Then
                            Dim infoMgr As New EmployeeInfoManager
                            MainGlobalData.mEmployee = emp
                            MainGlobalData.mEmployeeInfo = infoMgr.retrieveEmployeeInfoByEmployeeId(emp.id)
                            frmMain.Show()
                            Me.Hide()
                            Exit For
                        Else

                        End If
                    Else

                    End If
                End If

            Next
            

        End If
    End Sub

    Private Sub CloseButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Dispose()
        lblLoginSuccess.Show()
    End Sub

  

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim loginFrm As New loginform(Data)
        loginFrm.ShowDialog()
        Me.Dispose()
    End Sub

   
End Class